package threads.producer.consumer;

/**
 * 消费者
 */
public class Consumer implements Runnable {

    private Store store;
    private String name;

    public Consumer(Store store, String name) {
        this.store = store;
        this.name = name;
    }

    @Override
    public void run() {
        while (true) {
            try {
                String productName = store.getProduct();
                System.out.println(this.name + " 购买到： " + productName);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
